<{Tinclude "commom/admin_header"}>
<style>
     .jpinput{

         height: 20px;
     }
     .inputtxtvalue{
         display: none;
     }
 </style>
 <section id="container" >


      <!--顶部-->
      <{Tinclude"commom/admin_inner_header"}>
      <!--顶部-->
      
       <{Tinclude"commom/admin_left_menu"}>
       
       <section id="main-content">
          <section class="wrapper">
          	<h3><i class="<{if $___menuinfo["iconclass"]}><{$___menuinfo["iconclass"]}><{else}>fa fa-list-ul<{/if}>"></i><{$___menuinfo["base_name"]}></h3>
                <div class="row mt">
                    <div class="col-md-12">
                       <div class="form-panel">  
                           
                           
                           <div class='col-md-2'>
                               
                               <button class="btn btn-default btn-sm" data-toggle="modal" data-target="#addsetting"><span class="fa fa-plus-circle"></span>添加设置</button>
                           </div>
                          
                           <div class='clearfix'></div>
                           <div class='margin_top20'></div>
                           <div class="col-lg-12">
                           <div class="row">
                               
                              
  <section id="no-more-tables">                   
  <table class="table table-striped table-condensed table-hover cf">
      <thead class="cf">
        <tr>
            <th class="text-center">选项key</th>
          <th class="text-center">选项值</th>
          <th class="text-center">操作</th>
        </tr>
      </thead>
      <tbody>
          <{if $list}>
          <{foreach $list as $item}>
          <tr>
              <td data-title="选项key" class="text-center"><{$item["option_key"]}></td>
              <td data-title="选项值" class="text-center editvalue" data-rid="<{$item["id"]}>"><span class="txtvalue"><{$item["option_value"]}></span><span class="inputtxtvalue"><input class="form-control jpinput" /></span></td>
              <td data-title="操作" class="text-center">
                  <div class="btn-group">  
                      <a class="btn btn-primary btn-xs" href="<{echo Common::RewriteUrl("SystemSetting","delete","&id=".$item["id"]);}>" ><span class="fa fa-times"></span>删除</a>
                      
              </div>
              </td>
          </tr>
          <{/foreach}>
          <{/if}>
      </tbody>
  </table>
</section>
                              
                          <div class="col-md-12 text-center">
                           <?php Temp::Tinclude("commom/pager");?>
                          </div>
                     
                               
                               
                           </div>
                           </div>
                           <div class="clearfix"></div>
                           
                           
 
                           
                           
                           
                       </div>
                    </div>
                </div>
          </section>
       </section>
 </section>

<!--添加选项-->
<div class="modal fade" id="addsetting" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel">添加设置</h4>
      </div>
      <div class="modal-body">
          <form id="myform">
           <div class="form-group input-group col-md-12">
         <span class="input-group-addon">选项key</span>
         <input type="text"  class="form-control"   name="key" placeholder="选项key">
      </div>
              
      <div class="form-group input-group col-md-12">
         <span class="input-group-addon">选项值</span>
         <input type="text"  class="form-control"   name="value" placeholder="选项值">
      </div>
              
              
          </form>
          
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-success" id="btnsettingadd">提交</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<!--end添加选项-->


<script>
$("#btnsettingadd").click(function(){
    $.ajax({
        type:"POST",
        url:"<{echo Common::RewriteUrl("SystemSetting","public_ajax_addsetting");}>",
        data:$("#myform").serialize(),
        async:false,
        dataType:"json",
        success:function(data){
            if(data.status==1){
                alert("添加成功!");
                $('#rentadd').modal('hide');
                window.location.reload();
            }else{
                alert(data.msg);
            }
        }
    });


});

$(".editvalue").click(function(){
         var span=$(this).children(".txtvalue");  
          var id=$(this).data("rid");

         var spaninput=$(this).children(".inputtxtvalue");  
         var input=spaninput.children(".jpinput");
           if(span.css("display")!="none"){
                span.css("display","none");
                spaninput.css("display","inline-block");
                input.css("padding","6px 0px");
                input.css("font-size","12px");
                input.val(span.html());
                input.focus();
                input.blur(function(){
                     updatevalue(input.val(),id,span,spaninput,input);
                    
                });
            }
        });
    function updatevalue(val,id,span,spaninput,input){
         $.post("<{echo Common::RewriteUrl("SystemSetting","public_ajax_updatevalue");}>",{"vl":val,"id":id},function(data){
                if(data.status==1){
                    span.html(input.val());
                    
                    span.css("display","inline-block");
                    spaninput.css("display","none");
                    //alert("更新成功");
                    window.location.reload();
                }else{
                    alert(data.msg);
                }
            },"json");
    }    
</script>
<{Tinclude"commom/admin_footer"}>